import requests from "./request";
import mockRequests from "./mockRequest";

// 此处注意为单独暴露 需对象结构获取
// 三级分类api
export const reqCategoryList = () => {
    return requests({ url: 'product/getBaseCategoryList', method: 'get' })
}
// 搜索列表api
export const reqSearchList = (params) => requests({ url: '/list', method: 'post', data: params })

// mock之获取轮播图接口
export const mockReqBannerList = () => {
    return mockRequests({ url: '/banner', method: 'get' })
}
export const mockReqFloorList = () => {
    return mockRequests({ url: '/floor', method: 'get' })
}
// sku获取手机分页数据api
export const reqGoodsInfo = (skuId) => {
    return requests({ url: `/item/${skuId}`, method: 'get' })
}

//点击添加至购物车 /cart/addToCart/{ skuId }/{ skuNum }
export const reqAddOrShopCar = (skuId, skuNum) => {
    return requests({ url: `/cart/addToCart/${skuId}/${skuNum}`, method: 'post' })
}

// 获取购物车列表 /cart/cartList 无参数
export const reqCartList = () => {
    return requests({ url: '/cart/cartList', method: 'get' })
}


// 删除产品 /cart/deleteCart/{skuId} /cart/deleteCart/{skuId}
export const reqDeleteCart = (skuId) => {
    return requests({ url: `/cart/deleteCart/${skuId}`, method: 'DELETE' })
}


// 更新产品勾选状态 /cart/checkCart/{skuID}/{isChecked}
export const reqUpdataCartListIsChecked = (skuId, isChecked) => {
    return requests({ url: `/cart/checkCart/${skuId}/${isChecked}`, method: 'get' })
}


// 登陆注册
// 获取验证码 url: /api/user/passport/sendCode/{phone}
export const reqPhoneCode = (phone) => {
    return requests({ url: `/user/passport/sendCode/${phone}`, method: 'get' })
}


// 注册新用户 url:/api/user/passport/register
export const reqRegUser = (data) => {
    return requests({ url: '/user/passport/register', data, method: 'post' })
}

// 登陆 url:/api/user/passport/login
export const reqUserLogin = (data) => {
    return requests({ url: '/user/passport/login', data, method: 'post' })
}

// 获取用户信息 url:/api/user/userAddress/auth/findUserAddressList
export const reqUserInfo = () => {
    return requests({ url: '/user/passport/auth/getUserInfo', method: 'get' })
}

// 退出登录 url:/api/user/passport/logout
export const reqLoginOut = () => {
    return requests({ url: '/user/passport/logout', method: 'get' })
}

//获取用户地址信息
export const reqAddressInfo = () => requests({ url: `/user/userAddress/auth/findUserAddressList`, method: 'get' });


//获取商品清单数据
export const reqShopInfo = () => requests({ url: `/order/auth/trade`, method: 'get' });


// 提交订单 /api/order/auth/submitOrder?tradeNo={tradeNo}  post
export const reqSubmitOrder = (tradeNo, data) => requests({ url: `/order/auth/submitOrder?tradeNo=${tradeNo}`, method: 'post', data });

// 订单支付信息 /api/payment/weixin/createNative/{orderId}  get
export const reqPayInfo = (orderId) => requests({ url: `/payment/weixin/createNative/${orderId}`, method: 'get' });

// 查询订单支付状态 /api/payment/weixin/queryPayStatus/{orderId} get
export const reqPayStatus = orderId => requests({ url: `/payment/weixin/queryPayStatus/${orderId}`, method: 'get' })


// 获取为的订单列表（二级路由） /api/order/auth/{page}/{limit}
export const reqMyOrderList = (page, limit) => requests({ url: `/order/auth/${page}/${limit}`, method: 'get' })